package com.sun.async.enums;

/**
 * 导入任务状态枚举
 */
public enum ImportTaskStatusEnum {
    WAITING(0, "等待导入"),
    PROCESSING(1, "导入中"),
    SUCCESS(2, "成功"),
    FAILURE(3, "失败"),
    PARTIAL_SUCCESS(4, "部分成功");

    private final int code;
    private final String description;

    ImportTaskStatusEnum(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ImportTaskStatusEnum fromCode(int code) {
        for (ImportTaskStatusEnum status : ImportTaskStatusEnum.values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的任务状态码: " + code);
    }
}